package com.djf.Scrm.dataRelay.service;

import com.alibaba.fastjson2.JSON;
import com.djf.Scrm.dataRelay.dao.*;
import com.kingdee.bos.webapi.sdk.K3CloudApi;
import org.springframework.stereotype.Service;

import java.util.List;

import static org.assertj.core.api.Fail.fail;

/**
 * 获取客户信息
 */
@Service
public class ReceiveCustInfoService {
    static K3CloudApi api = new K3CloudApi();
    public void viewCustInfo() throws Exception {
        String sFormId = "GL_RPT_AccountBalance";
        TransactionModelDao transactionModelDao = new TransactionModelDao();
        TransactionAnalyseListDao analyse = new TransactionAnalyseListDao();
        FNumberDao fNumberDao = new FNumberDao();
        analyse.setFieldKeys("FBALANCEID,FBALANCENAME,FACCTTYPE,FACCTGROUP,FDETAILNUMBER,FDETAILNAME,FCyName");
        analyse.setSchemeId("97ffa1271acc4846b209ea05ac8dec9c");
        analyse.setStartRow(0);
        analyse.setLimit(200);
        analyse.setIsVerifyBaseDataField(false);

        fNumberDao.setFNumber("001");
        transactionModelDao.setFACCTBOOKID(fNumberDao);
        transactionModelDao.setFCURRENCY("1");
        transactionModelDao.setFSTARTYEAR("2021");
        transactionModelDao.setFSTARTPERIOD("12");
        transactionModelDao.setFENDYEAR("2021");
        transactionModelDao.setFBALANCELEVEL("1");
        analyse.setModel(transactionModelDao);

        String jsonString = JSON.toJSONString(analyse);
        String result = api.getSysReportData(sFormId,jsonString);
        ResultDao resultDao = JSON.parseObject(result, ResultDao.class);

        ResponseStatusDao responseStatus = resultDao.getResult();
        Boolean isSuccess = responseStatus.getIsSuccess();
        if(isSuccess) {
            System.out.println("科目余额表报表数据"+JSON.toJSONString(responseStatus));
        } else {
            fail("科目余额表报表数据"+JSON.toJSONString(responseStatus));
        }
    }




}
